from selenium import webdriver


class Drivers:
    _instance = None
    _driver = None

    def __new__(cls, *args, **kwargs):
        if not cls._instance:
            cls._instance = super().__new__(cls)
        return cls._instance

    @classmethod
    def get_driver(cls, browser="chrome"):
        if cls._driver is None:
            cls._driver = cls.create_driver(browser)
        return cls._driver

    @classmethod
    def create_driver(cls, browser):
        driver = None
        if browser.lower() == "chrome":
            driver = webdriver.Chrome()
        elif browser.lower() == "firefox":
            driver = webdriver.Firefox()
        elif browser.lower() == "ie":
            driver = webdriver.Ie()
        elif browser.lower() == "Safari":
            driver = webdriver.Safari()
        else:
            pass
        return driver


if __name__ == '__main__':
    pass
